package com.example.demo.mapper;

import com.example.demo.AppUtil.TokenSqlProvider;
import com.example.demo.entity.AnToken;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

/**
 * <p>
 * 用户Token Mapper 接口
 * </p>
 *
 * @author Mr.We
 * @since 2024-06-19
 */
@Mapper
public interface AnTokenMapper extends BaseMapper<AnToken> {
    @Select("select user_id," +
            "token," +
            "expire_time," +
            "update_time" +
            " from an_token" +
            " where user_id = #{userId}")
    AnToken queryByUserId(@Param("userId") Long userId);
    @Select("select user_id," +
            "        token," +
            "        expire_time," +
            "        update_time" +
            "        from an_token" +
            "        where token = #{token}")
    AnToken queryByToken(@Param("token") String token);
    @UpdateProvider(type = TokenSqlProvider.class, method = "update")
    void update(AnToken token);

}
